﻿using System.Windows.Controls;
using Foundation.ExtensionMethods;

namespace Foundation
{
    /// <summary>
    /// Base class for views.
    /// </summary>
    public class View : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="View"/> class.
        /// </summary>
        public View()
        {
            DataContextChanged +=
                (sender, args) =>
                    {
                        var viewModel = args.NewValue as ViewModel;
                        if (viewModel == null) return;
                        CommandBindings.AddRangeOnlyExclusiveItems(viewModel.CommandBindings);
                    };
        }
    }
}
